Skip to content

sharedfs: skip hypervisors without system templates - #13830

Merged
DaanHoogland merged 1 commit into
apache:4.22from
Dogface2k:fix/issue-13825-sharedfs-template
Sep 8, 2026
Merged

DaanHoogland merged 1 commit into
apache:4.22from
Dogface2k:fix/issue-13825-sharedfs-template

Conversation

@Dogface2k

Copy link
Copy Markdown
Collaborator

Fixes #13825

Summary

Prevent CreateSharedFileSystem from dereferencing a missing system VM template when a zone contains mixed hypervisor types.

Root cause

deploySharedFSVM() shuffles the supported hypervisors. When a hypervisor has no ready system VM template and another hypervisor remains, the existing null check fell through to template.getId() instead of trying the next hypervisor. This caused the reported intermittent NPE for mixed zones such as VMware plus External/MaaS.

Fix

Skip hypervisors without a ready system VM template while alternatives remain. Preserve the existing explicit CloudRuntimeException when the final candidate also has no template.

Validation

  • Reproduced the issue twice on the live CloudStack installation using an enabled, hostless External cluster alongside VMware; the exact template is null NPE occurred on the External-first attempt.
  • Removed all temporary clusters and test resources after reproduction; the zone returned to its original VMware-only state.
  • The focused regression test fails on the unfixed 4.22 branch with the exact NPE.
  • The focused Maven reactor test passes after the fix: 10 tests, 0 failures, 0 errors.

Scope

This is limited to SharedFS hypervisor template selection and its regression test. No UI, API contract, database schema, or deployment behavior is changed.

@DaanHoogland DaanHoogland left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clgtm

@codecov

codecov Bot commented Aug 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 17.69%. Comparing base (5328528) to head (a42798a).
⚠️ Report is 69 commits behind head on 4.22.

Additional details and impacted files
@@             Coverage Diff              @@
##               4.22   #13830      +/-   ##
============================================
- Coverage     17.69%   17.69%   -0.01%     
  Complexity    15835    15835              
============================================
  Files          5925     5925              
  Lines        533539   533541       +2     
  Branches      65274    65275       +1     
============================================
- Hits          94427    94424       -3     
- Misses       428435   428442       +7     
+ Partials      10677    10675       -2     
Flag Coverage Δ
uitests 3.69% <ø> (ø)
unittests 18.77% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@DaanHoogland

Copy link
Copy Markdown
Contributor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@DaanHoogland a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 18819

@DaanHoogland

Copy link
Copy Markdown
Contributor

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

@DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@blueorangutan

blueorangutan commented Aug 11, 2026 •

Copy link
Copy Markdown

[SF] Trillian test result (tid-16736)
Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
Total time taken: 52013 seconds
Marvin logs: [archive could not be removed: not found]
Smoke tests completed. 149 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File

@shwstppr

shwstppr commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@shwstppr a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 19081

@shwstppr shwstppr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested with a KVM and VMware mixed zone. VMware systemvm template was not present

Before fix, error was seen:

(localcloud) 🐱 > create sharedfilesystem filesystem=xfs diskofferingid=e53beb0a-5445-4b7d-8de7-4744314493db networkid=d79c34cf-4cec-4d4c-abba-77ae77856a72  serviceofferingid=67343c26-3788-4285-86d3-061e1a62591b zoneid=105faafc-5356-4280-ae1e-498732d49c40 name=abc1
{
  "account": "admin",
  "accountid": "1a34a13e-ab57-11f1-b57c-1e00b20009a0",
  "cmd": "org.apache.cloudstack.api.command.user.storage.sharedfs.CreateSharedFSCmd",
  "completed": "2026-09-08T11:32:14+0000",
  "created": "2026-09-08T11:32:14+0000",
  "domainid": "c9db7340-ab56-11f1-b57c-1e00b20009a0",
  "domainpath": "ROOT",
  "jobid": "147472a9-9ffa-4129-9daf-c0e250131c52",
  "jobinstancetype": "SharedFS",
  "jobprocstatus": 0,
  "jobresult": {
    "errorcode": 530,
    "errortext": "Cannot invoke \"com.cloud.storage.VMTemplateVO.getId()\" because \"template\" is null"
  },
  "jobresultcode": 530,
  "jobresulttype": "object",
  "jobstatus": 2,
  "userid": "1a352d7a-ab57-11f1-b57c-1e00b20009a0"
}
🙈 Error: async API failed for job 147472a9-9ffa-4129-9daf-c0e250131c52

After fix, deployment always happened on the KVM cluster.

if (template == null && !iter.hasNext()) {
if (template == null) {
if (iter.hasNext()) {
continue;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a log here would be helpful

@shwstppr shwstppr removed their assignment Sep 8, 2026
@DaanHoogland
DaanHoogland merged commit f493d99 into apache:4.22 Sep 8, 2026
26 checks passed
@github-project-automation github-project-automation Bot moved this from Ready to Done in CloudStack Testing Sep 8, 2026
abh1sar added a commit to shapeblue/cloudstack that referenced this pull request Sep 9, 2026
The 4.22 merge brought in testDeploySharedFSContinuesWhenTemplateIsMissingForNonLastHypervisor
from PR apache#13830, which covers the same skip-hypervisor-without-template path as
testDeploySharedFSSkipsHypervisorWithoutTemplate. It was written against
getSupportedHypervisorTypes(zoneId, false, null); deploySharedFSVM() now passes
forSystemVm=true, so its stubs were never used and MockitoJUnitRunner failed the
class with UnnecessaryStubbingException. Its External hypervisor scenario is also
unreachable now, since forSystemVm=true filters External out.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Development

Successfully merging this pull request may close these issues.

CreateSharedFileSystem NPE ("template is null") when zone has mixed hypervisor types

5 participants